/*
 * Copyright (C) 2015  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


/**
 * @file
 * @brief Generic functions to manage a 2D size.
 */


#ifndef PLANET_WARS_2D_RT_CORE_SIZE_2D_GENERIC_H
#define PLANET_WARS_2D_RT_CORE_SIZE_2D_GENERIC_H


/**
 * @brief Define a 2D size of specified type.
 * @param type A type
 */
#define DEFINE_SIZE_2D_STRUCT(type)			\
  struct size_2d_##type					\
  {							\
    type x;						\
    type y;						\
  };							\
  typedef struct size_2d_##type size_2d_##type;

/**
 * @brief Returns true if 2 2D sizes are equal, otherwise false.
 * @param size1 A first position
 * @param size2 A second position
 * @return True if 2 2D sizes are equal, otherwise false
 */
#define SIZE_2D_EQUALS(size1, size2)		\
  ( (size1).x == (size2).x &&			\
    (size1).y == (size2).y )

/**
 * @brief Returns the geometric aera of a 2D size.
 * @param size A size
 * @return The geometric aera of a 2D size
 */
#define SIZE_2D_AREA(size)  ( (size).x * (size).y )


#endif
